/*
 *  Handle encoding and decoding of passwords. 
 *  
 *  Currently uses the jasypt utility and is called by the spring security.
 * 
 * @author: Oren Zamir
 */
package org.valire.auth;

import org.jasypt.util.password.BasicPasswordEncryptor;
import org.springframework.dao.DataAccessException;
import org.springframework.security.authentication.encoding.PasswordEncoder;


public class PasswordEncoderImpl implements PasswordEncoder {

	@Override
	public String encodePassword(String rawPass, Object salt)
			throws DataAccessException {
		return new BasicPasswordEncryptor().encryptPassword(rawPass);
	}

	@Override
	public boolean isPasswordValid(String encPass, String rawPass, Object salt)
			throws DataAccessException {
		return  new BasicPasswordEncryptor().checkPassword(rawPass,encPass);
	}

}
